<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
    </head>
    <style>
        .div{
            font-size:50px;
        }
        .div{
            font-size: 16px;
        }
    </style>
    <body>
        <script>
            function cssByClassName(){
                var div2 = document.getElementById("div2");
                div2.className = "class2";
            }
            function cssByStyle(){
                var div2 = document.getElementById("div2");
                div2.style.fontSize="30px";
            }
            function cssByCssText(){
                var div2 = document.getElementById("div2");
                div2.style.cssText = "font-size:50px"
            }
          

</script>
<button onclick="cssByClassName()">通过className修改字号</button>
<button onclick="cssByStyle()">通过style修改字号</button>
<button onclick="cssByCssText()">通过style.cssText修改字号</button>
<div id="div2"name="div2"class="div">div文字</div>
</body>

</html>